<html>
	<head>
		<style type="text/css" media="screen">
			body {
				overflow: hidden;
			}
			
			#editor { 
				margin: 0;
				position: absolute;
				top: 0;
				bottom: 0;
				left: 0;
				right: 0;
			}
		</style>
		<title>Pad</title>
	</head>

	<body>
		<div id="editor">Connecting...</div>
		<script src="/lib/ace/ace.js" type="text/javascript" charset="utf-8"></script>
    <script src="/channel/bcsocket.js"></script>
		<script src="/share/share.uncompressed.js"></script>
		<script src="/share/ace.js"></script>
		<script>

    window.onload = function() {
        var editor = ace.edit("editor");
		editor.setReadOnly(true);

		var docName = "pad:" + document.location.hash.slice(1);

		sharejs.open(docName, 'text', function(error, doc) {
			if (error) {
				console.error(error);
				return;
			}

			if (doc.created) {
				doc.submitOp({i:'Edit me!'});
			}

			doc.attach_ace(editor);
			editor.setReadOnly(false);
		});
    };
		</script>
	</body>
</html>	

